<template>
  <div class="parent_register">
    <h1>注册</h1>
    <div class="login_parent">
      <div>
        <span>用户名</span>
        <input v-model="userName" placeholder="请输入用户名" />
      </div>
      <div>
        <span>密码</span>
        <input v-model="password" placeholder="请输入密码" />
      </div>
      <div>
        <button class="button2" v-on:click="submit">注册</button>
      </div>
    </div>
  </div>
</template>
<script>
import req from '../../src/api/fetch'
export default {
  name: 'register',
  data() {
    return {
      userName: '',
      password: ''
    }
  },
  methods: {
    submit() {
      let data = {
        userName: this.userName,
        password: this.password
      }
      req
        .post('register', data)
        .then(function(response) {
          console.log(response)
        })
        .catch(function(error) {
          console.log(error)
        })
        .then(function() {
          //always executed
        })
      // let userName = this.userName
      // let password = this.password
      // let axios = require('axios')
      // axios
      //   .post('http://localhost:9090/register', {
      //       userName: userName,
      //       password: password
      //   })
      //   .then(function(response) {
      //     console.log(response)
      //   })
      //   .catch(function(error) {
      //     console.log(error)
      //   })
      //   .then(function() {
      //     // always executed
      //   })
    }
  }
}
</script>

<style lang="less" scoped>
.parent_register {
  display: flex;
  flex-direction: column;
  width: 100%;
  justify-content: center;
  align-items: center;
  h1 {
    text-align: center;
    padding-top: 30px;
    margin-top: 0px;
    background: #00d8a0;
    color: #ffffff;
    height: 100px;
    width: 100%;
  }
  .login_parent {
    margin-top: 200;
    width: 100%;
    flex-direction: column;
    align-items: center;
    div {
      display: flex;
      flex-direction: row;
      width: 100%;
      height: 50px;
      align-items: center;
      justify-content: center;
      span {
        font-size: 15px;
        width: 50px;
        text-align: right;
        color: #000000;
        margin-left: 30px;
      }
      input {
        margin-left: 20px;
        width: 200px;
        height: 25px;
        border: 1px #00d8a0;
        border-style: solid;
        border-radius: 4px;
      }
      .button2 {
        width: 200px;
        height: 30px;
        margin-left: 50px;
        border-radius: 4px;
        margin-top: 20px;
        color: #ffffff;
        background: #00d8a0;
        border: 1px #00d8a0;
        border-style: solid;
      }
    }
  }
}
</style>
